package com.weibo4j.api.json;

import java.util.Date;
import java.util.List;

import org.apache.commons.lang.reflect.FieldUtils;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.ParserConfig;

public class JSON {

    static ParserConfig config = new ParserConfig();

    static {
        config.putDeserializer(Date.class, new DateDeserializer("EEE MMM dd HH:mm:ss Z yyyy"));
        try {
			FieldUtils.writeStaticField(ParserConfig.class, "global", config, true);
		} catch (IllegalAccessException e) {
		}
    }

    public static JSONObject parse(String json) {
        return com.alibaba.fastjson.JSON.parseObject(json);
    }

    public static <T> T parseObject(String json, Class<T> clazz) {
        return com.alibaba.fastjson.JSON.parseObject(json, clazz);
    }
    
    public static <T> List<T> parseArray(String json, Class<T> clazz) {
    	return com.alibaba.fastjson.JSON.parseArray(json, clazz);
    }
    
}
